package cn.readjava.service.impl;

import cn.readjava.bean.Role;
import cn.readjava.dao.RoleDao;
import cn.readjava.service.RoleService;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Set;

@Service
@CacheConfig(cacheNames = "role")
public class RoleServiceImpl implements RoleService {

    @Resource
    private RoleDao roleDao;

    @Override
    public Role getOne(Long id) {
        return roleDao.getOne(id);
    }

    @Override
    @Cacheable(key = "'user-role-id' + #p0")
    public Set<String> findAllRole(long userId) {
        return roleDao.findAllRole(userId);
    }
}
